#include <stdexcept>
#include <exception>

#include "log-util.h"
#include "string-util.h"

int sym_main(int argc,char **argv);
int symdb_main(int argc,char **argv);

void
terminate_handler_func()
{
    auto p = std::current_exception();
    if (p) {
        try {
            std::rethrow_exception(p);
        } catch (std::exception &e) {
            LOGE("%s",e.what());
        } catch (...) {
            LOGE("未知异常类型.");
        }
    } else {
        LOGE("这条语句应该是不可能发生的!");
    }
    exit(1);
    return ;
}

int
main(int argc,char **argv)
{
    std::set_terminate(terminate_handler_func);
    int ret = 0;
    if (strContain(argv[0],"symdb")) {
        ret = symdb_main(argc,argv);
    } else if (strContain(argv[0],"sym")) {
        ret = sym_main(argc,argv);
    } else {
        LOGE("未知操作: %s",argv[0]);
        ret = 1;
    }
    return ret;
}
